package com.vc.commons.transaction;

import javax.persistence.EntityManagerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.config.TxNamespaceHandler;

public class TransactionManager extends TxNamespaceHandler {
	
	@Autowired
	private LocalContainerEntityManagerFactoryBean entityManagerFactoryBean;

	public void add() {
		TxNamespaceHandler a = null;
		//org.springframework.transaction.config.TxAdviceBeanDefinitionParser a = new TxAdv;
		JpaTransactionManager jpaTransactionManager = new JpaTransactionManager();
		jpaTransactionManager.setEntityManagerFactory((EntityManagerFactory) entityManagerFactoryBean);
		
		//jpaTransactionManager.setJpaProperties(jpaProperties);
	}

	@Override
	public void init() {
		JpaTransactionManager jpaTransactionManager = new JpaTransactionManager();
		jpaTransactionManager.setEntityManagerFactory((EntityManagerFactory) entityManagerFactoryBean);
		registerBeanDefinitionParser("jta-transaction-manager", (BeanDefinitionParser) jpaTransactionManager);
		super.init();
	}
	
}
